package de.fzi.kasma.learner.function.kernel;

import de.fzi.kasma.learner.data.Data;
import de.fzi.kasma.learner.data.Dataset;
import de.fzi.kasma.learner.path.PathEdge;
import de.fzi.kasma.learner.path.PathGraph;
import edu.unika.aifb.graphindex.data.Table;
import edu.unika.aifb.graphindex.index.DataIndex;
import edu.unika.aifb.graphindex.index.PatternIndex;
import edu.unika.aifb.graphindex.storage.DataField;
import edu.unika.aifb.graphindex.storage.IndexDescription;
import edu.unika.aifb.graphindex.storage.StorageException;

public class ClauseKernel extends Kernel {

	private PathGraph pg;
	protected DataIndex m_idx;

	public ClauseKernel(PathGraph graph) {

		this.pg = graph;

	}

	@Override
	public double getValue(Data d) {
		// TODO Auto-generated method stub
		return 0;
	}

	public double getSimilarity(Data x, Data y, Dataset dataset)
			throws StorageException {

		return (dataset.querySuccessful(x, pg.edgeSet())
				&& dataset.querySuccessful(y, pg.edgeSet()) ? 1 : 0);

	}

	public Table<String> getTriples(PathGraph path) throws Exception {
		Table<String> triples = new Table<String>();
		for (PathEdge edge : path.edgeSet()) {
			triples = m_idx.getTriples(null,edge.getProperty(),null);
		}
		return triples;
	}
}
